package com.yaoxun.bored.controller.main;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.yaoxun.bored.model.sys.menu.Menu;
import com.yaoxun.bored.service.sys.menu.MenuService;
import com.yaoxun.bored.util.CommonUtils;

@Controller
public class IndexController {

	private static final String INDEX_PAGE = "index";
	
	@Inject
	private MenuService menuService;
	
	/**
	 * 跳转到首页
	 * @author Loren
	 * @createTime 2018年2月27日 下午2:31:28
	 * @return
	 */
	@RequestMapping("/index")
	public ModelAndView index() {
		ModelAndView mv = new ModelAndView(INDEX_PAGE);
		Integer[] roleIds = CommonUtils.getRoleIds();
		if(roleIds != null) {			
			List<Menu> menus = menuService.selectMenuUseIndex(roleIds, 0);
			mv.addObject("menus", menus);
		}
		return mv;
	}
		
	@RequestMapping("/welcome")
	public String welcome() {
		
		return "welcome";
	}
	
}
